package com.sky.controller.user;

import com.sky.dto.OrdersSubmitDTO;
import com.sky.result.Result;
import com.sky.service.user.UserOrderService;
import com.sky.vo.OrderSubmitVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * @Description TODO
 * @Author bo.li
 * @Date 2024/10/16 16:44
 * @Version 1.0
 */
@RestController
@RequestMapping("/user/order")
public class OrderController {

    @Autowired
    private UserOrderService userOrderService;

    @GetMapping("/getEstimatedDeliveryTime")
    public Result getEstimatedDeliveryTime(String customerAddress,Long shopId){
        LocalDateTime estimatedDeliveryTime = userOrderService.getEstimatedDeliveryTime(shopId, customerAddress);
        return Result.success(estimatedDeliveryTime);
    }

    @PostMapping("/submit")
    public Result submit(@RequestBody OrdersSubmitDTO submitDTO){
        OrderSubmitVO submit = userOrderService.submit(submitDTO);
        return Result.success(submit);
    }
}